import React from "react";
import { getProps } from "../../component";
import {WeaLocaleProvider} from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

export default class ComponentPropsPane extends React.Component {
  render() {
    const { com, onChange } = this.props;

    if (!com) {
      return (
        <div className='wea-f14' style={{ textAlign: 'center', color: '#aaa', paddingTop: '50%' }}>
          <p>{getLabel('502633','没有选定的字段') }</p>
          <p>{getLabel('502634','请添加或者选择一个字段')}</p>
        </div>
      );
    }

    const type = com.type.toLowerCase();
    const Props = getProps(type);

    if (!Props) return Props;

    return (
      <Props 
        key={com.uuid} 
        type={type} 
        data={com.config} 
        onChange={onChange} 
      />
    );
  }
}

ComponentPropsPane.defaultProps = {
  type: "",
  onChange: () => { }
};